package top.qform.disk;

import sun.misc.ProxyGenerator;
import top.qform.PayService;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Modifier;

/**
 * 手动写入磁盘
 */
public class ManualTest {
    public static void main(String[] args) throws IOException {
        String proxyName = "top.qform.dynamic.$Proxy0";
        Class[] interfaces = new Class[]{PayService.class};
        int accessFlags = Modifier.PUBLIC;
        // 将字节数组写到磁盘
        byte[] proxyClassFile = ProxyGenerator.generateProxyClass(proxyName, interfaces, accessFlags);
        File file = new File("D:\\ccj\\$Proxy0.class");
        OutputStream outputStream = new FileOutputStream(file);
        outputStream.write(proxyClassFile);
    }
}
